<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <link rel="icon" href="*{/images/favicon.ico}" type="image/x-icon" />
  <meta http-equiv="P3P" content="CP='NOI NID'">
  <meta http-equiv="_broadcast_from_" Content="1" />
  <script type="text/javascript" src="*{/js/jquery.js}"></script>
  <script type="text/javascript" src="*{/js/func.js}"></script>
  <script type="text/javascript" src="*{/js/base64.js}"></script>
	<title>文件管理</title>
  <link rel="stylesheet" href="*{/style/popup.css}">
  <script type="text/javascript" src="*{/js/popup_layer.js}"></script>
<style type="text/css">
html, body { padding:0px; margin:0px; width:100%; height:100%;overflow:auto;}
h1 { font-family: 'Overlock SC', cursive; margin:0 auto; }
h2 { font-family: 'Overlock SC', cursive; margin:10px 0px 0px 0px; padding:0px; }
.buttons { list-style-type:none; list-style-position:outside; margin:0px; padding:0px; clear:both; }
.buttons li { float:left }
.buttons label { font-size:12px;  line-height:20px;  }
.buttons input { }
p { font-size:12px; }
p .keywords {color:#800;}
a {color:bule;font-weight:bold;font-size:14px;text-decoration:none}
a:hover{color:red;}
a:active{color:yellow;}
.datatb {
  border:1px solid #CECECE;
  border-collapse: collapse ;
  margin-top:10px;
  margin-left:5px;
  width:calc(100% - 10px);
}
.datatb tr:nth-child(odd){
  background-color:#fbfdf9;
}
.datatb tr{
  border:1px solid #CECECE;
}
.datatb tr:hover{
  background-color:#FAFAD2;
}
.datatb tr td {
  border:1px solid #CECECE;
  padding-left:10px;
}
.datatb tr th {
  border-left:1px solid #CECECE;
  background-color:#EEE;
  text-align:center;
}
.t_status {
 width:30px;
  text-align:center;
}
.t_size {
  width:90px;
  text-align:center;
}
.t_date {
  width:115px;
  text-align:center;
}
.t_warning {
  background-color:#ffff33;
}
.t_error {
  background-color:#FF99FF;
}
</style>
</head>
<body>
<div class="main_div" _action="/N100042">
<div id="upload_area" style="display:none;width:300px;background-color:#FFFFFF;font-size:11px;">
    <div class="head"><div class="head-right"></div></div>
    <div class="main" id="main_area" >
        <h2 id="title_area"></h2>
        <a href="javascript:void(0)" id="close_popup_bt" class="closeBtn">关闭</a>
        <div id="main" style="width:300px;font-size:13px;height:120px;overflow:auto;">
            <form id="upload_form" method="POST" enctype="multipart/form-data" target="upload_frame" style="margin-left:10px;margin-top:10px;">
                <input name="uploads" type="file" multiple="multiple"/>
                <br /><br />
                <label for="need_ext">是否需要解压缩：</label><input type="checkbox" id="need_ext" name="need_ext" value="1" />
				        <br /><br />
                <input type="hidden" name="current_path" pk="datafld" _field="current_path"/>
                <input type="submit" value="上传文件" onclick="javascript:$('#upload_form').attr('action','*{/N100048.ha}');return true;"/>
            </form>
            <iframe id="upload_frame" name="upload_frame" src="" style="display:none;"></iframe>
        </div>
    </div>
</div>
<div id="upload_area_res" style="display:none;width:700px;background-color:#FFFFFF;font-size:11px;position:relative;">
	<div id="res_area" style="100%;overflow:auto;height:260px;background-color:#FFFFFF;">
		<table class="datatb" id="res_tb">
          <thead>
          	<tr>
              <th>文件</th>
        		  <th>方式</th>
        		  <th>上传大小</th>
        		  <th>本地大小</th>
        		  <th>上传日期</th>
        		  <th>本地日期</th>
        		  <th>状态</th>
          	</tr>
          </thead>
          <tbody id="datatb"></tbody>
        </table>
	</div>
  <div class="foot" style="width:100%;height:50px;position:relative;">
    <div class="foot-right">
      <a href="javascript:void(0)" id="close_res_bt" class="closeBtn" onclick="javascript:window.location.reload();">关闭</a>
    </div>
  </div>
</div>
  <div class="right_div" style="margin-top:10px;">
    当前文件夹：<input type="text" style="width:400px;" pk="datafld" _field="current_path" id="current_path" disabled/>
    &nbsp;&nbsp;
    <a href="#" onclick="javascript:return addNewFile(this);" target="_blank">新增文件</a>
    &nbsp;&nbsp;
    <a href="javascript:return false;" id="bt_upload" onclick="javascript:uploadFile(this); return false;" target="_blank">上传文件</a>
    &nbsp;&nbsp;&nbsp;&nbsp;
    <input type="text" id="new_path_name"/> <a href="#" onclick="javascript:newPath();return false;">新增文件夹</a>
    <span id="driver_list_area" style="display:none;">
      &nbsp;&nbsp;&nbsp;&nbsp;
      盘符：
      <select id="driver_list" onchange="changeDriver(this);">
        <option value="">请选择</option>
      </select>
    </span>
    <table id="tb" class="datatb">
      <tr>
        <th>文件</th>
        <th style="width:170px;text-align:cneter;padding-right:10px;">更新时间</th>
        <th style="width:100px;text-align:center;">大小</th>
        <th style="width:140px;text-align:center;">操作</th>
      </tr>
      <tr id="tr">
        <td align="left"><a href="#" style="color:black;" forder_style="color:red" onclick="javascript:return openPath(this);" pk="datafld" _field="name,path,is_path,is_path,info" _set2="path" _set3="is_path" _checktype4="if:1{forder_style:style}"  _set5="title" target="_blank"></a></td>
        <td align="center" pk="datafld" _field="up_time"></td>
        <td align="center" pk="datafld" _field="size"></td>
        <td align="center">
          <a href="#" target="_blank" onclick="javascript:return downloadFile(this,'@',true);" pk="datafld" _field="path" _keyword="@" _set="onclick">预览</a>
          <a href="#" onclick="javascript:return openPath(this);" pk="datafld" _field="path,is_path" _set1="path" _set2="is_path" target="_blank">打开</a>
          <a href="#" target="_blank" onclick="javascript:return downloadFile(this,'@');" pk="datafld" _field="path" _keyword="@" _set="onclick">下载</a>
          <a href="#" onclick="javascript:deleteFile('@','$');return false;" pk="datafld" _field="path,is_path" _keyword1="@" _keyword2="$" _set1="onclick" _set2="onclick" title="每次删除前都会自动做备份（除非用谷歌浏览器按住Shift键点击删除）">删除</a>
        </td>
      </tr>
    </table>
  </div>
  <div class="clear"></div>
</div>
<script type="text/javascript" defer>
    var uploadPopup;
    function newPath(){
        postData("*{/N100050.ha}","bpath="+$("#current_path").val()+"&path_name="+$("#new_path_name").val());
        window.location.reload();
    }
    function uploadFile(node){
      uploadPopup = new PopupLayer({popupBlk:"#upload_area",closeBtn:"#close_popup_bt",useFx:false});
      $("#upload_form")[0].reset();
      return false;
    }
    function downloadFile(node,fileName,show){
		if(!show){
			show = "false";
		}else{
			show = "true";
		}
       node.href = "*{/N100047.ha}&bpath="+$("#current_path").val()+"&show="+show+"&file_name="+fileName;
       return true;
    }
    function showDirver(){
      var res = getJson("*{/N100125.ha}");
      if(res && res.rs){
        res = res.rs;
      }
      if(!res || !res.length || res.length<2){
        return;
      }
      var sel = $("#driver_list");
      for(var i=0;i<res.length;i++){
        sel.append("<option value='"+res[i]+"'>"+res[i]+"</option>");
      }
      $("#driver_list_area").show();
    }
    showDirver();
    
    function changeDriver(node){
      var val = $(node).val();
      if(val==""){
        return;
      }
      window.location = "?path=&bpath="+val;
    }
    
    function openPath(node){
        node = $(node);
        var path = node.attr("path");
        var bpath = $("#current_path").val();
        var isPath = node.attr("is_path");
        if(isPath=="1"){
            window.location = "*{/file/index.htm}&path="+path+"&bpath="+bpath;
            return false;
        }else{
            node[0].href = "*{/file/source.htm}&bpath="+bpath+"&file_name="+path;
            return true;
        }
    }
    function addNewFile(node){
        node.href = "*{/file/source.htm}&bpath="+$("#current_path").val();
    }
    function deleteFile(fileName,isPath){
        if(fileName=="." || fileName==".."){
          return false;
        }
      	var noBackup = "";
        var noBackupMsg = "";
        if(event && event.shiftKey){
           noBackup = "1";
           noBackupMsg = "【！！！不做备份！！！】  ";
        }
        if(isPath=="1"){
            if(!confirm(noBackupMsg+"确认是否要删除该文件夹以及其内部的所有文件:["+fileName+"]")){
                return false;
            }
            if(!confirm(noBackupMsg+"请再次确认是否要删除该文件夹以及其内部的所有文件:["+fileName+"]")){
                return false;
            }
            postData("*{/N100046.ha}","no_backup="+noBackup+"&bpath="+$("#current_path").val()+"&file_name="+fileName);
        }else{
            if(!confirm(noBackupMsg+"确认是否删除文件:["+fileName+"]")){
                return false;
            }
            postData("*{/N100046.ha}","no_backup="+noBackup+"&bpath="+$("#current_path").val()+"&file_name="+fileName);
        }
        window.location.reload();
    }
    function uploadCompleted(json){
      if(uploadPopup){
        uploadPopup.close();
      }
      if(!json){
        return;
      }
      if(json.status && json.status=="0"){
        alert(json.msg);
        return;
      }
      var tb = $("#upload_area_res").find("#datatb");
      tb.empty();
      var mode;
      var status;
      var objSize;
      var srcSize;
      var objTime;
      var srcTime;
      var trColor;
      for(var i=0;i<json.length;i++){
        mode    = "--";
        status  = "--";
        objSize = "--";
        srcSize = "--";
        objTime = "--";
        srcTime = "--";
        trColor = "";
        if(json[i]["mode"]=="1"){
          mode = "覆盖";
          trColor = " t_warning";
        }else if(json[i]["mode"]=="0"){
          mode = "新增";
        }else{
          mode = "--"; 
        }
        if(json[i]["status"]=="1"){
          status = "成功";
        }else{
          status = "失败";
          trColor = " t_error";
        }
        if(json[i]["obj_size"]){
          objSize = json[i]["obj_size"];
        }else{
          objSize = "--";
        }
        if(json[i]["src_size"]){
          srcSize = json[i]["src_size"];
        }else{
          srcSize = "--";
        }
        if(json[i]["obj_time"]){
          objTime = json[i]["obj_time"];
        }else{
          objTime = "--";
        }
        if(json[i]["src_time"]){
          srcTime = json[i]["src_time"];
        }else{
          srcTime = "--";
        }
        tb.append("<tr><td>"+json[i]["path"]+"</td><td class=\"t_status\">"
                    +mode+"</td><td class=\"t_size\">"+objSize+"</td><td class=\"t_size\">"+srcSize
                    +"</td><td class=\"t_date\">"+objTime+"</td><td class=\"t_date\">"
                    +srcTime+"</td><td class=\"t_status\">"+status+"</td></tr>");
      }
      new PopupLayer({trigger:"#bt_upload",popupBlk:"#upload_area_res",closeBtn:"#close_res_bt",useFx:false});
    }
</script>
</body>
</html>